﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO.Ports;

namespace SimpleTestFrameForNFC
{
    //[InstrumentInterfaceTypeAnno(InstrumentInterfaceType.Serial)]
    class UDP3305S
    {
        public SerialPort serial;

        public void connect(int port) {
            if (serial == null) {
                serial = new SerialPort("COM" + port, 9600, Parity.None, 8, StopBits.One);                
            }

            if (!serial.IsOpen) {
                serial.Open();
            }
        }

        public void SetVolAndON(double vol1, double vol2)
        {
            serial.Write("SOURce1:VOLTage " + vol1 + "\n");
            serial.Write("SOURce2:VOLTage " + vol2 + "\n");
            serial.Write(":OUTPut:STATe CH1, ON\n");
            serial.Write(":OUTPut:STATe CH2, ON\n");
        }

        public void PowerOff()
        {
            serial.Write(":OUTPut:STATe CH1, OFF\n");
            serial.Write(":OUTPut:STATe CH2, OFF\n");
        }

        public void colse() {
            if (serial!=null) {
                serial.Close();
                serial = null;
            }
        }
    }
}
